/**
 * @Author Puzzle
 * @Date 2022/6/13 11:21 上午
 **/

package model

import (
	"zsc-boot/core/orm"
)

// ServiceDepartment 结构体
// 如果含有time.Time 请自行import time包
type ServiceDepartment struct {
	orm.Model
	Name               string              `json:"name" form:"name" gorm:"column:name;comment:名称;"`
	Principal          uint                `json:"principal" form:"principal" gorm:"column:principal;comment:负责人;"`
	ParentId           uint                `json:"parentId" form:"parentId" gorm:"column:parent_id;comment:上级部门;"`
	PrincipalEmployees ServiceUserSimple   `json:"principalEmployees" form:"principalEmployees" gorm:"foreignKey:Principal"` // 负责人
	MembersList        []ServiceUserSimple `json:"membersList" form:"membersList" gorm:"foreignKey:DepId"`
	Children           []ServiceDepartment `json:"children" form:"children" gorm:"foreignKey:ParentId"` // 子级部门
	City               string              `json:"city" gorm:"city;comment:城市;default:'';size:32"`
	ClearDay           *uint16             `json:"clearDay" gorm:"clear_day;comment:清洗限天数"`
	UserIds            []uint              `json:"userIds" gorm:"-"`
}

// TableName ServiceDepartment 表名
func (ServiceDepartment) TableName() string {
	return "service_department"
}

func (ServiceDepartment) TableComment() string {
	return "组织"
}

type ServiceDepartmentSimple struct {
	ID        uint   `json:"Id" form:"Id" gorm:"column:id;primaryKey;comment:主键ID"` // 主键ID
	Name      string `json:"name" form:"name" gorm:"column:name;comment:名称;"`
	Principal uint   `json:"principal" form:"principal" gorm:"column:principal;comment:负责人;"`
}

func (ServiceDepartmentSimple) TableName() string {
	return "service_department"
}
